/**
 * Copyright 2011 Honeywell Federal Manufacturing & Technologies, LLC. This material was produced under U.S. Government
 * contract DE-ACO4-01AL66850, Honeywell Federal Manufacturing & Technologies, LLC, (FM&T) with the U. S. Department of
 * Energy for the operation of the Kansas City Plant . The U.S. Government has rights to use, reproduce, and distribute
 * this software.  NEITHER THE GOVERNMENT NOR Honeywell Federal Manufacturing & Technologies, LLC, MAKES ANY WARRANTY,
 * EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE.  If software is modified to produce
 * derivative works, such modified software should be clearly marked, so as not to confuse it with the version available
 * from FM&T.
 *
 * Additionally, this program is free software; you can redistribute it and/or modify it under the terms of the GNU
 * General Public License Version 3 published by the Free Software Foundation. Accordingly, this program is distributed in
 * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this library.
 * If not, see http://www.gnu.org/licenses/.
 */
package org.braintrain.domain;

import org.braintrain.domain.types.KnowledgeLevel;
import org.braintrain.domain.types.TrainingRating;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;
import java.util.TreeSet;

@Entity
@Table( name="braintrain_evaluations" )
public class EvaluationData extends BrainTrainBase implements Comparable<EvaluationData>{

    private static final long serialVersionUID = -8521555013440999705L;
    
    private Date evalDate;
    private Set<EvaluationBackground> background = new TreeSet<EvaluationBackground>();
    private KnowledgeLevel knowledgeLevel;
    private TrainingRating expectations;
    private TrainingRating quality;
    private TrainingRating amount;
    private TrainingRating jobHelp;
    private TrainingRating userFriendly;
    private TrainingRating reaction;
    private String usefulLesson;
    private String moduleDrop;
    private String moduleAdd;
    private String likeLeast;
    private String likeMost;
    
    private Module module;

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="module_id") 
    public Module getModule() {
        return module;
    }

    public void setModule(Module module) {
        this.module = module;
    }

    @Enumerated(EnumType.STRING)
    public TrainingRating getAmount() {
        return amount;
    }

    public void setAmount(TrainingRating amount) {
        this.amount = amount;
    }

    @ManyToMany(targetEntity=EvaluationBackground.class, fetch=FetchType.LAZY)
    @JoinTable(
            name="BRAINTRAIN_EVAL_BACKGROUND",
            joinColumns={@JoinColumn(name="EVAL_ID")},
            inverseJoinColumns={@JoinColumn(name="BACKGROUND_ID")}
        )
    public Set<EvaluationBackground> getBackground() {
        return background;
    }

    public void setBackground(Set<EvaluationBackground> background) {
        this.background = background;
    }

    @Enumerated(EnumType.STRING)
    public TrainingRating getExpectations() {
        return expectations;
    }

    public void setExpectations(TrainingRating expectations) {
        this.expectations = expectations;
    }

    @Enumerated(EnumType.STRING)
    public TrainingRating getJobHelp() {
        return jobHelp;
    }

    public void setJobHelp(TrainingRating jobHelp) {
        this.jobHelp = jobHelp;
    }

    @Enumerated(EnumType.STRING)
    public KnowledgeLevel getKnowledgeLevel() {
        return knowledgeLevel;
    }

    public void setKnowledgeLevel(KnowledgeLevel knowledgeLevel) {
        this.knowledgeLevel = knowledgeLevel;
    }

    @Column(length=4000)
    public String getLikeLeast() {
        return likeLeast;
    }

    public void setLikeLeast(String likeLeast) {
        this.likeLeast = likeLeast;
    }

    @Column(length=4000)
    public String getLikeMost() {
        return likeMost;
    }

    public void setLikeMost(String likeMost) {
        this.likeMost = likeMost;
    }

    @Column(length=4000)
    public String getModuleAdd() {
        return moduleAdd;
    }

    public void setModuleAdd(String moduleAdd) {
        this.moduleAdd = moduleAdd;
    }

    @Column(length=4000)
    public String getModuleDrop() {
        return moduleDrop;
    }

    public void setModuleDrop(String moduleDrop) {
        this.moduleDrop = moduleDrop;
    }

    @Enumerated(EnumType.STRING)
    public TrainingRating getQuality() {
        return quality;
    }

    public void setQuality(TrainingRating quality) {
        this.quality = quality;
    }

    @Enumerated(EnumType.STRING)
    public TrainingRating getReaction() {
        return reaction;
    }

    public void setReaction(TrainingRating reaction) {
        this.reaction = reaction;
    }

    @Column(length=4000)
    public String getUsefulLesson() {
        return usefulLesson;
    }

    public void setUsefulLesson(String usefulLesson) {
        this.usefulLesson = usefulLesson;
    }

    @Enumerated(EnumType.STRING)
    public TrainingRating getUserFriendly() {
        return userFriendly;
    }

    public void setUserFriendly(TrainingRating userFriendly) {
        this.userFriendly = userFriendly;
    }

    public Date getEvalDate() {
        return evalDate == null ? null : (Date) evalDate.clone();
    }

    public void setEvalDate(Date evalDate) {
        this.evalDate = evalDate;
    }

    public int compareTo(EvaluationData o) {
        return this.getEvalDate().compareTo(o.getEvalDate());
    }
    
    
}